﻿@model UserProfileDto
@section MainStyle{
    <!-- bradcam_area_start -->
    <div class="courses_details_banner">
        <div class="container">
            <div class="row">
                <div class="col-xl-6">
                    <div class="course_text">
                        <h3>BigRoom </h3>
                        <h3> Wellcom With Us</h3>
                        <h3>@User.Identity.Name</h3>



                    </div>
                </div>
            </div>
        </div>
    </div>
    <!-- bradcam_area_end -->
}
<div style="text-align:center">
    <p class="mb-5 mt-5">
        <a asp-action="Create" asp-controller="Groups" class="boxed_btn">Create Group</a>
    </p>

    <table class="table">
        <caption style="text-align:center">Group You Join</caption>
        <thead class="thead-dark">
            <tr>
                <th>Group</th>
                <th>Create At</th>
                <th>Create By</th>
                <th>Modified By</th>
                <th>Last Modified</th>
                <th></th>
            </tr>
        </thead>
        <tbody>
            @foreach (var item in Model.Groups)
            {
            <tr>
                <td>
                    @item.Group.Name
                </td>
                <td>
                    @item.Group.CreatedOn
                </td>
                <td>
                    @item.Group.CreatedBy.GetNameFromEmail()
                </td>
                <td>
                    @item.Group.LastModifiedOn
                </td>
                <td>
                    @item.Group.LastModifiedBy.GetNameFromEmail()
                </td>
                <td style="float:right;">
                    <button class="btn btn-primary text-white" data-clipboard-text="@item.Group.CodeJion" data-bs-toggle="tooltip" data-bs-placement="bottom" title="Copy CodeJoin"><i class="far fa-copy"></i></button>
                    <a asp-controller="Groups" asp-action="GroupYouAdmin" asp-route-id="@item.Group.Id" class="btn btn-warning text-white"><i class="fas fa-info-circle"></i></a>
                    <form  action="UserGroups/LeaveFromGroup" method="post"  style="display: inline-block">
                        <input name="id" value="@item.Id" style="display: none" />
                        <button class="btn btn-light"  title="Leave Group"><i class="fas fa-sign-out-alt"></i></button>
                    </form>
                </td>
            </tr>
            }
        </tbody>
    </table>
    <br />
    <table class="table">
        <caption style="text-align:center">Groups you Admin</caption>

        <thead class="thead-light">
            <tr>
                <th>Group</th>
                <th>Create At</th>
                <th>Create By</th>
                <th>Modified By</th>
                <th>Last Modified</th>
                <th></th>
            </tr>
        </thead>
        <tbody>
            @foreach (var item in Model.GroupsThatAdmin)
            {
                <tr>
                    <td>
                        @item.Name
                    </td>
                    <td>
                        @item.CreatedOn
                    </td>
                    <td>
                        @item.CreatedBy.GetNameFromEmail()
                    </td>
                    <td>
                        @item.LastModifiedOn
                    </td>
                    <td>
                        @item.LastModifiedBy.GetNameFromEmail()
                    </td>
                    <td style="float:right;">
                        <button class="btn btn-primary text-white" data-clipboard-text="@item.CodeJion" data-bs-toggle="tooltip" data-bs-placement="bottom" title="Copy CodeJoin"><i class="far fa-copy"></i></button>
                        <a asp-controller="Groups" asp-action="GroupYouAdmin" asp-route-id="@item.Id" class="btn btn-warning text-white"><i class="fas fa-info-circle"></i></a>
                        <a class="btn btn-info text-white" asp-controller="Groups" asp-action="Edit" asp-route-id="@item.Id"><i class="far fa-edit"></i></a>
                        <a class="btn btn-danger" asp-controller="Groups" asp-action="Delete" asp-route-id="@item.Id"><i class="fas fa-trash-alt"></i></a>
                    </td>
                </tr>
            }
        </tbody>
    </table>

</div>
@section Scripts{
<script src="~/js/site.js"></script>
    <script src="~/js/clipboard.min.js"></script>
<script>
    var clipboard = new ClipboardJS('.btn');

    clipboard.on('success', function (e) {
        console.info('Action:', e.action);
        console.info('Text:', e.text);
        console.info('Trigger:', e.trigger);

        e.clearSelection();
        console.log("Success");
    });

    clipboard.on('error', function (e) {
        console.error('Action:', e.action);
        console.error('Trigger:', e.trigger);
        console.log("Failed");
    });
</script>
  
}